/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidade;

import com.thoughtworks.xstream.XStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author tiago
 */
public class TesteLeituraXML {

    public static void main(String args[]) {

        XStream xs = new XStream();
        xs.alias("root", List.class);
        xs.alias("Atributo", Atributo.class);
        xs.alias("Entidade", Entidade.class);

        List<Entidade> entidades;
        try {
            File f = new File("testeXmlHashmap.xml");
            FileReader fr = new FileReader(f);
            BufferedReader br = new BufferedReader(fr);
            entidades = (List) xs.fromXML(br);
            Entidade ent1 = entidades.get(0);
            HashMap<String, IAtributo> atributosEnt1 = ent1.getAtributos();
            for (Iterator it = atributosEnt1.values().iterator(); it.hasNext();) {
                IAtributo at = (IAtributo) it.next();
                System.out.println(at.getNome());
                System.out.println(at.getValor().toString());
            }
        } catch (FileNotFoundException ex) {
            Logger.getLogger(TesteLeituraXML.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
